package com.mcg.ash;


import cn.hutool.core.io.FileUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.mcg.plugin.omcxdb.Omcx;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 服务器端实现远程接口。
 * 必须继承UnicastRemoteObject，以允许JVM创建远程的存根/代理。
 */
public class AshOmc extends UnicastRemoteObject implements com.mcg.ash.IAshOmc {
    private int numberOfComputations;

    protected AshOmc() throws RemoteException {
        numberOfComputations = 0;
    }
    Map<String, String> mm =null;

    @Override
    public Map<String, byte[]> test(String filePath, Omcx omc) throws Exception {
        ExcelReader reader = ExcelUtil.getReader(FileUtil.file("C:\\work\\wangyuan.xlsx"));

         if(mm==null) {
             mm = new HashMap<>();
             List<List<Object>> read = reader.read(2, reader.getRowCount());
             for (List<Object> shu : read) {
                 String b = shu.get(3).toString();
                 String a = shu.get(2).toString();
                 mm.put(b, a);
             }
         }
        return TelnetTool.zhumap(filePath,mm,omc);
    }
    @Override
    public String test1(String a) throws Exception {
        System.out.println("输出："+a);
        String b = "--------------------"+a+"--------------------";
        return b;
    }
}
